package org.xenon.vote.util;

import java.util.Random;

public class CharUtil {
    private static final String codes = "23456789abcdefghjkmnopqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ";
    private static final Random r = new Random();

    /**
     * 获取随机字符
     *
     */
    public static char getRandomChar() {
        int index = r.nextInt(codes.length());
        return codes.charAt(index);
    }

    public static String getRandomString(int length) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++)
            sb.append(getRandomChar());
        return sb.toString();
    }
}
